/**   
* @Title: TestV4.java 
* @Package test 
* @Description: TODO 
* @author mazhongrui  
* @date 2019年8月1日 上午11:23:06 
* @version    
*/
package com.xoa.plugin;

import com.xoa.model.archive.DocArchive;
import com.xoa.service.archive.ArchWebServiceImplService;
import com.xoa.service.archive.impl.ArchWebServiceImpl;
import com.xoa.util.archive.CommonUtils;
import com.xoa.util.archive.HttpUploadFile;
import org.apache.commons.io.FilenameUtils;

import javax.xml.namespace.QName;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;


/** 
 * @ClassName: TestWs 
 * @Description: TODO
 * @version  
 */
public class TestWs {

	public static void main(String[] args) throws MalformedURLException {
		URL url = new URL("http://106.13.80.96:8060/Webservice/Collect/archivesV4?wsdl");
		QName qName = new QName("http://127.0.0.1/Webservice/Collect/archivesV4", "ArchWebServiceImplService");
		ArchWebServiceImplService archWebServiceImplService = new ArchWebServiceImplService(url,qName);
		ArchWebServiceImpl archWebServiceImpl = archWebServiceImplService.getArchWebServiceImplPort();
		DocArchive docArchive = new DocArchive();
	        //调用客户端提交数据
	        docArchive.setAppid("oaws");//调用系统
	        docArchive.setApptoken("1573611620235600517");//校验代码
	        docArchive.setCompanycode("0232");//单位编码


	        docArchive.setOwner("admin");//隶属人id
	        docArchive.setFondsname("福州城市建设投资集团有限公司");//全宗名称
	        docArchive.setArchcode("123456-30-2017");//文件档号
	        docArchive.setDoccode("1");//件号
	        docArchive.setTitle("关于xxx设备资料66");//合同名称
	        docArchive.setDocnumber("J001-02-0023");//合同编号
	        docArchive.setAuthor("张XX");//责任者
	        docArchive.setDocdate("2018-01-01");//日期
	        docArchive.setYear("2018");//年度
	        docArchive.setRetentionperiod("30年");//保管期限
	        docArchive.setSecurity("公开");//密级
	        docArchive.setSecuritytime("5");//保密年限
	        docArchive.setPagenum("24");//页数
	        docArchive.setDepartment("项目建设部");//隶属（归档）部门名称
	        docArchive.setDepartmentid("10015");//隶属（归档）部门代码
	        docArchive.setDepartmentsn("建设");//隶属（归档）部门代字
	        docArchive.setSection("隶属处室");//隶属（归档）
	        docArchive.setSectionid("12344123");//隶属（归档）处室代码
	        docArchive.setCreater("zhangxx");//创建（归档）人id
	        docArchive.setCreatername("张XX");//创建（归档）人姓名
	        docArchive.setCreatetime("2018-01-01 00:00:00");//创建（归档）时间
	        docArchive.setSubject("设备 资料");//主题词
	        docArchive.setMemo("");//备注
	        docArchive.setRelatearchives("");//关联公文
	        docArchive.setKnownscope("");//知悉范围
	        docArchive.setRelatepersons("");//知悉人（多个人员id）
	        docArchive.setRelatedepartments("");//知悉部门（多个部门ID）
	        
	        //*********附件上传 start**********
	        File file1 = new File("C:\\Users\\CYS\\Desktop\\档案接口\\CallDemo\\docu\\办文单.doc");
	        File file2 = new File("C:\\Users\\CYS\\Desktop\\档案接口\\CallDemo\\docu\\科学技术.pdf");
	        //实际存储名称
	        String uuidName4file1 = CommonUtils.getpfpID() + "." + FilenameUtils.getExtension(file1.getName());
	        String uuidName4file2 = CommonUtils.getpfpID() + "." +  FilenameUtils.getExtension(file2.getName()); 
	        //appid：由档案系统提供; path：为相对路径,其中/oaws：表文书目录，/oaht：表示合同目录,服务器会根据路径自动创建文件夹
	        HttpUploadFile.fileUpload("http://106.13.80.96:8081/HttpUpload/uploadFile?appid=www&path=/oaws/2021/20210719/" + uuidName4file1, file1);
	        HttpUploadFile.fileUpload("http://106.13.80.96:8081/HttpUpload/uploadFile?appid=www&path=/oaws/2021/20210720/" + uuidName4file2, file2);
	        //*********附件上传 end************
	        
	        //匹配路径 具体格式可参照：ArchiveUtils.getServerAttachment
	        //name：附件标题，ext：扩展名，file：存储路径 + 实际存储名称。注：路径内不含 oaws 和 owht
	        String attachment = "[{\"name\":\"办文单\",\"ext\":\"doc\",\"file\":\"/2021/20210719/"+uuidName4file1+"\"},"
	        					+"{\"name\":\"科学技术\",\"ext\":\"pdf\",\"file\":\"/2021/20210720/"+uuidName4file2+"\"}]";
	        docArchive.setAttachment(attachment);//电子文件信息
	        docArchive.setExt1("");//主办部门
	        docArchive.setExt2("");//合作方
	        docArchive.setExt3("");//签约人
	        docArchive.setExt4("");
	        docArchive.setExt5("");
	        docArchive.setExt6("");
	        docArchive.setExt7("");
	        docArchive.setExt8("");
	        docArchive.setExt9("");
	        docArchive.setExt10("");
	        docArchive.setExt11("");
	        docArchive.setExt12("");
	        docArchive.setExt13("");
	        docArchive.setExt14("");
	        docArchive.setExt15("");
	        docArchive.setExt16("");
	        docArchive.setExt17("");
	        docArchive.setExt18("");
	        docArchive.setExt19("");
	        docArchive.setExt20("");
		String result = archWebServiceImpl.receiveDocArchive(docArchive);
		System.out.println(result);
		
	}
	
}
